$(function(){
	fn_get_menu('2');
	fn_get_left_menu('2','2-1');
});

//点击更换手机注册验证码
function reloadCode(){
    var verify=document.getElementById('imgJavaCode');
    verify.setAttribute('src','../static/createCode/makePhoneCertPic.jsp?it='+Math.random());
}

//验证手机注册时java生成的验证码
var regPhoneJavaCodeIsok = false;
function checkRegJavaCode(){
	var code = $("#regJavaCode").val().trim();
	if(code==''){
	$("#msgRegJavaCode").html("请输入验证码");
		return false;
	}
	$.ajax({  
		url:"../user/phoneCode",
		type:"post",
		data:{"code":code},
		dataType:"json",
		success:function(arr){ 
			if(arr=="0"){
				regPhoneJavaCodeIsok =true;
				$("#msgRegJavaCode").html("<img src='../them/images/correct.png' />");
			}else{
				regPhoneJavaCodeIsok =false;
				$("#msgRegJavaCode").html("验证码不正确");
			}
		}            
	});
}


// 空白（空格、换行、tab）和逗号分隔的字符串，变成用逗号分隔  
function getSplitString(str) {  
    var arr = str.split(",");  
  
    var resources = "";  
    for (var i = 0; i < arr.length; i++) {  
        var arr1 = arr[i].split(/\s+/);  
  
        for (var j = 0; j < arr1.length; j++) {  
            if (jQuery.trim(arr1[j]) != "") {  
                resources += jQuery.trim(arr1[j]) + ",";  
            }  
        }  
    }  
  
    resources=resources.substring(0,(resources.length-1));
    return resources;  
}  

function onwaybill(){
	var billNo = changedouhao($("#billNo").val());
	
	
	//billNo=billNo.replace(/\s+/g,",");
	//var reg=/^([1-9]{1}([0-9]{11}|[0-9]{7}),{0,1}){1,10}$/;
	
	billNo = getSplitString(billNo);
	var reg=/^([1-9]{1}([0-9]{11}|[0-9]{7}|[0-9]{13}),{0,1}){1,10}$/;
	
	if(!reg.test(billNo)){
		alert("请输入合法的运单号");
		return;
	}
	var regJavaCode = $("#regJavaCode").val();
	if(checkRegJavaCode()==false){
		return;
	}
	if(regPhoneJavaCodeIsok==false){
		return;
	}
	location.href="waybillinfo.jsp?billNo="+billNo+"&regJavaCode="+regJavaCode;
}

function changedouhao(str){ 
	str=str.replace(/，/ig,','); 
	return str; 
} 